package com.airnewslinkosky.ticket.util;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.sql.Timestamp;

import android.os.Environment;

/**
 * 
 * @author zouxs
 */
public class LogUtils {
	
	
	/**
	 * 打印日志到文件
	 * @param tag
	 * @param msg
	 * @param logFileName
	 */
	public static void fileLog(String tag, String msg, String logFileName){
		if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
			return;
		}
		try {
			File logFile = new File(Environment.getExternalStorageDirectory(), logFileName);
			if(!logFile.exists()){
				logFile.createNewFile();
			}
			BufferedWriter bw = new BufferedWriter(new FileWriter(logFile, true));
			bw.append(new Timestamp(System.currentTimeMillis()).toString())
			.append("=====").append(tag)
			.append("-----").append(msg).append("\n");
			bw.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
